import DialogBaseUI from "../../custom/DialogBaseUI";
import {EndType} from "./public/GameDefine_nbddz";
import {PlayerData} from "../PlayerData";

const {ccclass, property} = cc._decorator;
@ccclass
export default class NbddzGameEndUI extends DialogBaseUI {
    @property([cc.Node])
    playerEnds:Array<cc.Node> = [];
    @property(cc.Label)
    endLabel:cc.Label = null;
    show(bankerSeat:number,msg){
        if(msg.endType==EndType.END_DIZHU){
            this.endLabel.string="地主胜"
        }else{
            this.endLabel.string="农民胜"
        }
        for(let i=0;i<msg.score.length;i++){
            let localSeat = PlayerData.serverSeatToLocalSeat(i);
            let player = PlayerData.getPlayerByServerSeat(i);
            let score:cc.Label = cc.find("score",this.playerEnds[localSeat]).getComponent(cc.Label);
            let name:cc.Label = cc.find("name",this.playerEnds[localSeat]).getComponent(cc.Label);
            let head:cc.Sprite = cc.find("name",this.playerEnds[localSeat]).getComponent(cc.Sprite);
            let dizhu:cc.Node = cc.find("dizhu",this.playerEnds[localSeat]);
            if(msg.score[i]>0){
                score.string = "+"+msg.score[i];
            }else{
                score.string = msg.score[i];
            }
            name.string = player.nickname;
            //ToolUtils.loadNetImage(player.headimg,head);
            dizhu.active=false;
            if(i==bankerSeat){
                dizhu.active=true;
            }
        }
        this.node.active = true;
    }
}